<template lang="html">
  <div class="detail">
    <go-back></go-back>
    <div class="detail-wrapper">
      <h2>{{details.title}}</h2>
      <ul>
          <li>浏览量:{{details.readingAmount}}</li>
          <li>发布时间:{{details.createdAt | timeFormat}}</li>
      </ul>
      <div v-html="content" class="table_style"></div>
      <div class="img-wrapper">
        <div class="img-container" v-for="item in _filterObj(details.files)">
            <img :src="item.url" alt="">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {getDetail} from 'api/article.js'

import {filterObj} from 'common/js/filterObj.js'

import GoBack from 'components/index/goback/goback'

export default {
  data() {
    return {
      details: {},
      content: ''
    }
  },
  created() {
    this._getDetail()
  },
  methods: {
    _getDetail() {
      getDetail(this.$route.params.id).then((res) => {
        this.details = res
        this.content = res.content.replace(/&nbsp;/g, '')
      })
    },
    _filterObj(obj) {
      return filterObj(obj)
    }
  },
  components: {
    GoBack
  }
}
</script>

<style lang="scss">
.detail{
  width: 100%;
  .line{
    height: 44px;
    background: rgba(231,231,231,0.2);
    border-bottom: 1px solid rgba(221,221,221,0.5);
    width: 1200px;
    margin-left: 18%;
    span{
      font-size: 14px;
      color: #777;
      line-height: 44px;
      margin-left: 10px;
      cursor: pointer;
    }
  }
  .detail-wrapper{
    width: 1200px;
    margin:0 auto 100px;
    h2{
      text-align: center;
      font-size: 36px;
      line-height: 36px;
      padding-top: 40px;
      padding-bottom: 20px;
    }
    ul{
      display: flex;
      justify-content: center;
      margin-bottom: 30px;
      li{
        padding-left: 3%;
        color: #777777;
        /*&:not(:first-child){
          padding-right: 36px;
        }*/
      }
    }
    .table_style{
      tr{
        border:1px solid #000;
        td,th{
          border: 1px solid #000;
          text-align: center;
        }
      }
    }
    div{
      line-height: 36px;
      /*padding-bottom: 5%;*/
      text-align: left;
      // p:first-child{
      //   text-align: center;
      // }
      p{
        line-height: 50px;
        color: #222;
        font-family: '微软雅黑';
      }
      b{
        font-size: 20px;
        padding-top: 20px;
        padding-bottom: 10px;
        color: #000;
        font-family: '微软雅黑';
       /* b{
          color: red;
        }
        font{
          color:blue;
        }*/
      }
    }
    .img-wrapper{
      display: flex;
      justify-content: space-between;
      .img-container{
        img{
          /*margin-bottom: 50px;*/
         /*width: 300px;*/
          /*height: 300px;*/
          //display: inline-block;
          float: left;
        }
      }
    }
    .detail-content{
      margin-top: 50px;
      margin-bottom: 50px;
      .titleone{
        font-size: 24px;
      }
      .titletwo{
        font-size: 24px;
        margin-top: 60px;
      }

    }
  }
}
</style>
